--- /dev/null
+/*
+ File for "converting" GPSBabel's testo shell script into
+ MS Windows NT/2000/XP command script.
+
+ It is limited to:
+ - testo using the shell variable PNAME for the executable program being tested
+ - testo using ${TMPDIR} for the temporary directory in which test files are created
+ - testo using compare as the name of a shell function for comparing test results
+ - no other shell script conversion is performed apart from whole line comments;
+ unconverted script is discarded, not even included as comments in the output
+
+ Copyright (C) 2003 Mark Bradley, mrcb.sf.gpsb@osps.net
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+
+#define LINELENGTH 200
+#define MYNAME "MkWinTesto"
+
+// ------------------------------------------------------------------------------------
+int f_outputLine (
+ char *pcWhat,
+ FILE *pfWhere)
+{
+ int iLength;
+ int iThisChar;
+
+ // ===========================
+ // Returns 0 is output has new line
+ // Returns 1 is line ended on \ for continuation and no new line
+
+ iLength = strlen(pcWhat);
+ if (iLength > 2) {
+ if ((*(pcWhat+iLength-3) == '\\') &&
+ (*(pcWhat+iLength-2) == '\r') &&
+ (*(pcWhat+iLength-1) == '\n')) {
+
+ for (iThisChar=0; iThisChar < iLength-3; iThisChar++)
+ fputc(*(pcWhat+iThisChar), pfWhere);
+ return 1;
+ }
+ }
+ if (iLength > 1) {
+ if ((*(pcWhat+iLength-2) == '\\') &&
+ (*(pcWhat+iLength-1) == '\n')) {
+
+ for (iThisChar=0; iThisChar < iLength-2; iThisChar++)
+ fputc(*(pcWhat+iThisChar), pfWhere);
+ return 1;
+ }
+ }
+ if (iLength > 0) {
+ if (*(pcWhat+iLength-1) == '\\') {
+
+ for (iThisChar=0; iThisChar < iLength-1; iThisChar++)
+ fputc(*(pcWhat+iThisChar), pfWhere);
+ return 1;
+ }
+ }
+
+ fputs(pcWhat, pfWhere);
+ fputs("\r\n", pfWhere);
+ return 0;
+}
+
+// ------------------------------------------------------------------------------------
+int main(
+ int argc,
+ char *argv[])
+{
+ char acLineIn[LINELENGTH];
+ char acLineOut[LINELENGTH];
+
+ int iThisChar;
+ int iStart;
+ int iTarget;
+ int iTranslateQuotes;
+ int iQuoteCount;
+ int iPrevLineContinues = 0;
+
+ FILE *pfTestoIn;
+ FILE *pfTestoOut;
+
+ // ===========================
+
+ pfTestoIn = fopen(argv[1], "rb");
+
+ if (pfTestoIn == NULL) {
+ fatal(MYNAME ": %s for reading\n",argv[1]);
+ }
+ else {
+ pfTestoOut = fopen ("wintesto.cmd", "wb");
+ if (pfTestoOut == NULL) {
+ fatal (MYNAME ": wintesto.cmd for writing\n");
+ }
+ else {
+
+ // Output the .CMD preamble
+ f_outputLine("REM", pfTestoOut);
+ f_outputLine("REM Simple Windows NT/2000/XP .cmd version of GPSBabel testo script", pfTestoOut);
+ f_outputLine("REM", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+ f_outputLine("SET TMPDIR=%TEMP%\\WINTESTO", pfTestoOut);
+ f_outputLine("MKDIR %TMPDIR% 2>NUL:", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+ f_outputLine("GOTO :REALSTART", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+ f_outputLine(":COMPARE", pfTestoOut);
+ f_outputLine("SET PARAM1=%1", pfTestoOut);
+ f_outputLine("SET PARAM2=%2", pfTestoOut);
+ f_outputLine("REM Test if param2 was a dir rather than a file, if so add a \\* to make fc work", pfTestoOut);
+ f_outputLine("FOR %%A IN (%2) DO IF \"d--------\"==\"%%~aA\" SET PARAM2=%2\\*", pfTestoOut);
+ f_outputLine("FOR /f \"delims=\" %%a IN ('fc %PARAM1% %PARAM2%') DO IF \"x%%a\"==\"xFC: no differences encountered\" GOTO :EOF", pfTestoOut);
+ f_outputLine("ECHO %* are not the same - pausing. ^C to quit if required", pfTestoOut);
+ f_outputLine("PAUSE", pfTestoOut);
+ f_outputLine("GOTO :EOF", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+ f_outputLine("REM ==================================", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+ f_outputLine(":SORTandCOMPARE", pfTestoOut);
+ f_outputLine("SORT <%1 >%TMPDIR%\\s1", pfTestoOut);
+ f_outputLine("SORT <%2 >%TMPDIR%\\s2", pfTestoOut);
+ f_outputLine("CALL :COMPARE %TMPDIR%\\s1 %TMPDIR%\\s2", pfTestoOut);
+ f_outputLine("GOTO :EOF", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+ f_outputLine("REM ==================================", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+ f_outputLine(":REALSTART", pfTestoOut);
+ f_outputLine("", pfTestoOut);
+
+
+
+ while (! feof(pfTestoIn)) {
+ // Read in the next line or stop if done
+ fgets(acLineIn, LINELENGTH-1, pfTestoIn);
+ if (acLineIn == NULL) break;
+
+ // Is the whole line a comment? Replace the hash with REM and output the rest
+ if (acLineIn[0] == '#') {
+ acLineOut[0]='\0';
+ strcat (acLineOut,"REM");
+ // Strip out any ending new lines
+ for (iThisChar=1; iThisChar<LINELENGTH; iThisChar++) {
+ if ((acLineIn[iThisChar] == '\0') ||
+ (acLineIn[iThisChar] == '\n') ||
+ ((acLineIn[iThisChar] == '\r') && (acLineIn[iThisChar+1] == '\n'))) {
+
+ acLineOut[iThisChar+2] = '\0';
+ break;
+ }
+ acLineOut[iThisChar+2] = acLineIn[iThisChar];
+ }
+ iPrevLineContinues = f_outputLine(acLineOut, pfTestoOut);
+ }
+ // Are we near the top of testo where the program variable is defined?
+ else if (strncmp("PNAME=${PNAME:-",acLineIn,15) == 0) {
+ acLineOut[0]='\0';
+ strcat (acLineOut,"SET PNAME=");
+ // Copy the rest of the PNAME assignment stopping at a close } or EOL
+ for (iThisChar=15; iThisChar<LINELENGTH; iThisChar++) {
+ if ((acLineIn[iThisChar] == '}') ||
+ (acLineIn[iThisChar] == '\0') ||
+ (acLineIn[iThisChar] == '\n') ||
+ ((acLineIn[iThisChar] == '\r') && (acLineIn[iThisChar+1] == '\n'))) {
+ acLineOut[iThisChar-5] = '\0';
+ break;
+ }
+ if (acLineIn[iThisChar] == '/') {
+ acLineOut[iThisChar-5] = '\\';
+ } else {
+ acLineOut[iThisChar-5] = acLineIn[iThisChar];
+ }
+ }
+ iPrevLineContinues = f_outputLine(acLineOut, pfTestoOut);
+ if (iPrevLineContinues == 1) f_outputLine("", pfTestoOut);
+ iPrevLineContinues = f_outputLine("IF NOT EXIST %PNAME% ECHO Can't find %PNAME%&& GOTO :EOF", pfTestoOut);
+ // fputs("\r\n", pfTestoOut);
+ }
+ else {
+ // Every other line....
+ iStart = 0;
+ iTarget = 0;
+ iTranslateQuotes = 0;
+ iQuoteCount = 0;
+ acLineOut[0] = '\0';
+
+ // Is this one of the test sequences mostly (all?) starting with a cleanup?
+ if (strncmp("rm -f ",acLineIn,6) == 0) {
+ iStart = 6;
+ strcat(acLineOut, "DEL ");
+ iTarget = 4;
+ }
+ // Is this one of the test sequences where the program is run?
+ if (strncmp("${PNAME} ",acLineIn,9) == 0) {
+ iStart = 9;
+ strcat(acLineOut, "%PNAME% ");
+ iTarget = 8;
+ }
+ // Is this one of the test sequences where we compare the rest?
+ if (strncmp("compare ",acLineIn,8) == 0) {
+ iStart = 8;
+ strcat(acLineOut, "CALL :COMPARE ");
+ iTarget = 14;
+ }
+ // Is this one of the test sequences where we compare the rest?
+ if (strncmp("sort_and_compare ",acLineIn,17) == 0) {
+ iStart = 17;
+ strcat(acLineOut, "CALL :SORTandCOMPARE ");
+ iTarget = 21;
+ }
+ // Is this one of the test sequences where we prepare some data?
+ if (strncmp("echo \"",acLineIn,6) == 0) {
+ iStart = 6;
+ strcat(acLineOut, "ECHO ");
+ iTarget = 5;
+ iTranslateQuotes = 1;
+ iQuoteCount = 1;
+ }
+ if ((iStart > 0) ||
+ (iPrevLineContinues == 1)) {
+
+ if (iStart == 0) {
+ // Didn't match, so can only possibly be a continued line
+ // Skip spaces, then process the rest of line as "normal"
+ for (iThisChar=0; iThisChar<LINELENGTH; iThisChar++) {
+ // end of line checks
+ if ((acLineIn[iThisChar] == '\0') ||
+ (acLineIn[iThisChar] == '\n') ||
+ ((acLineIn[iThisChar] == '\r') && (acLineIn[iThisChar+1] == '\n'))) {
+ iStart = iThisChar;
+ break;
+ }
+ // Stop skipping spaces and tabs if this isn't one (arg!)
+ if ((acLineIn[iThisChar] != ' ') &&
+ (acLineIn[iThisChar] != '\t')) {
+ iStart = iThisChar;
+ break;
+ }
+
+ } // for ... skipping spaces on a continued line
+ } // if... is this a continued line?
+
+
+ // Need to replace the shell variable replacement syntax with Windoze one
+ // and swap slashes in directory separators
+
+ for (iThisChar=iStart; iThisChar<LINELENGTH; iThisChar++) {
+ if ((acLineIn[iThisChar] == '\0') ||
+ (acLineIn[iThisChar] == '\n') ||
+ ((acLineIn[iThisChar] == '\r') && (acLineIn[iThisChar+1] == '\n'))) {
+ acLineOut[iTarget+iThisChar-iStart] = '\0';
+ break;
+ }
+ if (acLineIn[iThisChar] == '"') {
+ // Are we starting quotes or in quotes?
+ // Either way, don't copy out the quotes themselves
+ iQuoteCount = (iQuoteCount > 0) ? 0 : 1;
+ iTarget--;
+ continue;
+ }
+ if (acLineIn[iThisChar] == '%') {
+ if (iQuoteCount == 1) {
+ // Need to double up the number of %s
+ acLineOut[iTarget+iThisChar-iStart] = '%';
+ iTarget++;
+ }
+ // This also caters for where we're not in quotes,
+ // so must just copy the % once
+ acLineOut[iTarget+iThisChar-iStart] = '%';
+ continue;
+ }
+ if (acLineIn[iThisChar] == '>') {
+ if (acLineIn[iThisChar-1] == ' ') {
+ // Need to remove any spaces between echo and redirection
+ // as NT/2000/XP adds this to the output and mostly this is NOT wanted
+ iTarget--;
+ }
+ acLineOut[iTarget+iThisChar-iStart] = '>';
+ continue;
+ }
+ if (strncmp("${TMPDIR}",acLineIn+iThisChar,9) == 0) {
+ strcpy(acLineOut+iTarget+iThisChar-iStart,"%TMPDIR%");
+ // %TMPDIR% is one char shorter than ${TMPDIR}
+ iTarget--;
+ // skip forward to the end of the string matched
+ // (less one as the loop will add one)
+ iThisChar += 8;
+ } else if (acLineIn[iThisChar] == '/') {
+ acLineOut[iTarget+iThisChar-iStart] = '\\';
+ } else {
+ // part of a literal, so copy the text
+ acLineOut[iTarget+iThisChar-iStart] = acLineIn[iThisChar];
+ }
+ } // for
+ iPrevLineContinues = f_outputLine(acLineOut, pfTestoOut);
+ // fputs("\r\n", pfTestoOut);
+ }
+ else {
+ // We didn't match the start of the line, so
+ // - if blank, print it
+
+ if ((acLineIn[0] == '\n') ||
+ (acLineIn[0] == '\0') ||
+ ((acLineIn[0] == '\r') && (acLineIn[1] == '\n') && (acLineIn[2] == '\0'))) {
+ iPrevLineContinues = f_outputLine("", pfTestoOut);
+ }
+
+ } // else... didn't match a start of line - so check rest of line
+
+ } // else ... catchall to mathing things on the start of the line
+
+ } // while <stuff to read>
+
+ // We're done
+ fclose(pfTestoIn);
+ fclose(pfTestoOut);
+ }
+ }
+}
--- /dev/null
+REM\r
+REM Simple Windows NT/2000/XP .cmd version of GPSBabel testo script\r
+REM\r
+\r
+SET TMPDIR=%TEMP%\WINTESTO\r
+MKDIR %TMPDIR% 2>NUL:\r
+\r
+GOTO :REALSTART\r
+\r
+:COMPARE\r
+SET PARAM1=%1\r
+SET PARAM2=%2\r
+REM Test if param2 was a dir rather than a file, if so add a \* to make fc work\r
+FOR %%A IN (%2) DO IF "d--------"=="%%~aA" SET PARAM2=%2\*\r
+FOR /f "delims=" %%a IN ('fc %PARAM1% %PARAM2%') DO IF "x%%a"=="xFC: no differences encountered" GOTO :EOF\r
+ECHO %* are not the same - pausing. ^C to quit if required\r
+PAUSE\r
+GOTO :EOF\r
+\r
+REM ==================================\r
+\r
+:SORTandCOMPARE\r
+SORT <%1 >%TMPDIR%\s1\r
+SORT <%2 >%TMPDIR%\s2\r
+CALL :COMPARE %TMPDIR%\s1 %TMPDIR%\s2\r
+GOTO :EOF\r
+\r
+REM ==================================\r
+\r
+:REALSTART\r
+\r
+\r
+SET PNAME=.\gpsbabel\r
+IF NOT EXIST %PNAME% ECHO Can't find %PNAME%&& GOTO :EOF\r
+\r
+\r
+\r
+\r
+\r
+REM Geocaching .loc\r
+DEL %TMPDIR%\gl.loc\r
+%PNAME% -i geo -f geocaching.loc -o geo -F %TMPDIR%\gl.loc\r
+CALL :COMPARE %TMPDIR%\gl.loc reference\r
+\r
+REM GPSUtil\r
+DEL %TMPDIR%\gu.wpt\r
+%PNAME% -i geo -f geocaching.loc -o gpsutil -F %TMPDIR%\gu.wpt\r
+CALL :COMPARE %TMPDIR%\gu.wpt reference\r
+\r
+REM GPSman \r
+DEL %TMPDIR%\gm.gm %TMPDIR%\gm.gm+\r
+%PNAME% -i geo -f geocaching.loc -o gpsman -F %TMPDIR%\gm.gm\r
+%PNAME% -i gpsman -f %TMPDIR%\gm.gm -o gpsutil -F %TMPDIR%\gm.gm+\r
+CALL :COMPARE %TMPDIR%\gm.gm+ %TMPDIR%\gu.wpt\r
+\r
+REM GPX\r
+DEL %TMPDIR%\gl.gpx %TMPDIR%\gpx.gpx\r
+%PNAME% -i geo -f geocaching.loc -o gpx -F %TMPDIR%\gl.gpx\r
+%PNAME% -i gpx -f %TMPDIR%\gl.gpx -o gpsutil -F %TMPDIR%\gpx.gpx\r
+CALL :COMPARE %TMPDIR%\gpx.gpx %TMPDIR%\gu.wpt\r
+\r
+REM Magellan Mapsend\r
+DEL %TMPDIR%\mm.mapsend %TMPDIR%\mm.gps\r
+%PNAME% -i geo -f geocaching.loc -o mapsend -F %TMPDIR%\mm.mapsend\r
+%PNAME% -i mapsend -f %TMPDIR%\mm.mapsend -o gpsutil -F %TMPDIR%\mm.gps\r
+CALL :COMPARE %TMPDIR%\mm.gps %TMPDIR%\gu.wpt\r
+\r
+REM Magellan serial\r
+REM TODO\r
+\r
+REM Tiger\r
+REM This one is a little tacky, becuase it's a very lossy format.\r
+REM so we simply test we can write it, and then read it and write it and\r
+REM get an identical file back.\r
+DEL %TMPDIR%\tiger\r
+%PNAME% -i geo -f geocaching.loc -o tiger -F %TMPDIR%\tiger\r
+%PNAME% -i tiger -f %TMPDIR%\tiger -o tiger -F %TMPDIR%\tiger2\r
+CALL :COMPARE %TMPDIR%\tiger %TMPDIR%\tiger2\r
+\r
+REM CSV (Comma separated value) data.\r
+\r
+%PNAME% -i geo -f geocaching.loc -o csv -F %TMPDIR%\csv.csv\r
+%PNAME% -i csv -f %TMPDIR%\csv.csv -o csv -F %TMPDIR%\csv2.csv\r
+CALL :COMPARE %TMPDIR%\csv2.csv %TMPDIR%\csv.csv \r
+\r
+REM\r
+REM Delorme TopoUSA 4 is a CSV strain. \r
+REM\r
+DEL %TMPDIR%\xmap-1.gpx %TMPDIR%\xmap-2.gpx %TMPDIR%\xmap\r
+%PNAME% -i xmap -f reference\xmap -o xmap -F %TMPDIR%\xmap\r
+%PNAME% -i xmap -f reference\xmap -o gpx -F %TMPDIR%\xmap-1.gpx\r
+%PNAME% -i xmap -f %TMPDIR%\xmap -o gpx -F %TMPDIR%\xmap-2.gpx\r
+CALL :COMPARE %TMPDIR%\xmap-1.gpx %TMPDIR%\xmap-2.gpx\r
+CALL :COMPARE reference\xmap %TMPDIR%\xmap\r
+\r
+REM PCX (Garmin mapsource import) file format\r
+DEL %TMPDIR%\mm.pcx %TMPDIR%\pcx.gps\r
+%PNAME% -i geo -f geocaching.loc -o pcx -F %TMPDIR%\mm.pcx\r
+%PNAME% -i pcx -f %TMPDIR%\mm.pcx -o gpsutil -F %TMPDIR%\pcx.gps\r
+CALL :COMPARE %TMPDIR%\mm.gps %TMPDIR%\gu.wpt\r
+\r
+REM Magellan file format\r
+%PNAME% -i magellan -f reference\magfile -o magellan -F %TMPDIR%\magfile\r
+CALL :COMPARE %TMPDIR%\magfile reference\magfile\r
+\r
+REM Navitrak DNA marker format\r
+%PNAME% -i dna -f reference\dnatest.txt -o dna -F %TMPDIR%\dnatest.txt\r
+CALL :COMPARE %TMPDIR%\dnatest.txt reference\dnatest.txt\r
+\r
+REM PSP (PocketStreets 2002 Pushpin (.PSP)) file format. Use mxf as an \r
+REM intermediate format to avoid binary FP anomalies on compareerent platforms.\r
+DEL %TMPDIR%\psp.mxf %TMPDIR%\mxf.psp\r
+%PNAME% -i psp -f reference\ps.psp -o mxf -F %TMPDIR%\psp.mxf\r
+%PNAME% -i geo -f geocaching.loc -o mxf -F %TMPDIR%\mxf.psp\r
+CALL :COMPARE %TMPDIR%\psp.mxf %TMPDIR%\mxf.psp\r
+\r
+REM MXF (Maptech Exchange Format) file format\r
+DEL %TMPDIR%\mx.mxf %TMPDIR%\mxf.mxf\r
+%PNAME% -i mxf -f reference\mxf.mxf -o mxf -F %TMPDIR%\mx.mxf\r
+%PNAME% -i mxf -f %TMPDIR%\mx.mxf -o mxf -F %TMPDIR%\mxf.mxf\r
+CALL :COMPARE %TMPDIR%\mxf.mxf reference\r
+\r
+REM tmpro (TopoMapPro Places) file format\r
+DEL %TMPDIR%\topomappro.txt %TMPDIR%\mxf.mxf\r
+%PNAME% -i tmpro -f reference\topomappro.txt -o tmpro -F %TMPDIR%\tmp.txt\r
+%PNAME% -i tmpro -f %TMPDIR%\tmp.txt -o tmpro -F %TMPDIR%\topomappro.txt\r
+CALL :COMPARE %TMPDIR%\topomappro.txt reference\r
+\r
+REM TPG (NG Topo!) file format\r
+REM This is hard to test as the datum conversions create minute\r
+REM inconsistencies in the coordinates. So.. we test our i/o \r
+REM against a format that rounds higher than we care to compare\r
+REM for binary data. \r
+DEL %TMPDIR%\topo.mxf %TMPDIR%\tpg.mxf %TMPDIR%\geo.tpg\r
+%PNAME% -i geo -f geocaching.loc -o tpg -F %TMPDIR%\geo.tpg\r
+%PNAME% -i tpg -f %TMPDIR%\geo.tpg -o mxf -F %TMPDIR%\tpg.mxf\r
+%PNAME% -i tpg -f reference\tpg.tpg -o mxf -F %TMPDIR%\topo.mxf\r
+CALL :COMPARE %TMPDIR%\tpg.mxf %TMPDIR%\topo.mxf\r
+\r
+REM OZI (OziExplorer 1.1) file format\r
+DEL %TMPDIR%\oz.ozi %TMPDIR%\ozi.ozi\r
+%PNAME% -i ozi -f reference\ozi.ozi -o ozi -F %TMPDIR%\oz.ozi\r
+%PNAME% -i ozi -f %TMPDIR%\oz.ozi -o ozi -F %TMPDIR%\ozi.ozi\r
+CALL :COMPARE %TMPDIR%\ozi.ozi reference\r
+\r
+REM Holux support is a little funky to test. Becuase it loses precision,\r
+REM if we convert it to another format, we lose accuracy (rounding) in the\r
+REM coords, so converting it so something else and comparing it never works.\r
+REM So we verify that we can read the reference and write it and get an\r
+REM identical reference.\r
+%PNAME% -i holux -f reference\paris.wpo -o holux -F %TMPDIR%\paris.wpo\r
+CALL :COMPARE reference\paris.wpo %TMPDIR%\paris.wpo\r
+\r
+REM Magellan NAV Companion for PalmOS\r
+REM This format is hard to test, because each record and the database itself\r
+REM contains the time of creation, so two otherwise identical files won't\r
+REM compare accurately. In any case, the files are binary so compare wouldn't\r
+REM like them. So, we convert the reference file to gpsutil and the converted\r
+REM file to gpsutil and make sure they're the same, and that they're the same\r
+REM as one converted on a known-working installation. Unfortunately, this does\r
+REM not verify that the appinfo block was written correctly. However, it does\r
+REM successfully test for some endianness errors that might otherwise go \r
+REM unnoticed.\r
+DEL %TMPDIR%\magnav.pdb %TMPDIR%\magnav.gpu %TMPDIR%\magnavt.gpu\r
+%PNAME% -i geo -f geocaching.loc -o magnav -F %TMPDIR%\magnav.pdb\r
+%PNAME% -i magnav -f %TMPDIR%\magnav.pdb -o gpsutil -F %TMPDIR%\magnav.gpu\r
+%PNAME% -i magnav -f reference\magnav.pdb -o gpsutil -F %TMPDIR%\magnavt.gpu\r
+CALL :COMPARE %TMPDIR%\magnavt.gpu %TMPDIR%\magnav.gpu\r
+CALL :COMPARE reference\gu.wpt %TMPDIR%\magnav.gpu\r
+\r
+REM GPSPilot Tracker for PalmOS\r
+REM This test is eerily similar to the NAV Companion test. In fact, the \r
+REM converted reference file (magnavr.gpu) is identical.\r
+DEL %TMPDIR%\gpspilot.pdb %TMPDIR%\gpspilot.gpu %TMPDIR%\gpspil_t.gpu\r
+%PNAME% -i geo -f geocaching.loc -o gpspilot -F %TMPDIR%\gpspilot.pdb\r
+%PNAME% -i gpspilot -f %TMPDIR%\gpspilot.pdb -o gpsutil -F %TMPDIR%\gpspilot.gpu\r
+%PNAME% -i gpspilot -f reference\gpspilot.pdb -o gpsutil -F %TMPDIR%\gpspil_t.gpu\r
+CALL :COMPARE %TMPDIR%\gpspil_t.gpu %TMPDIR%\gpspilot.gpu\r
+CALL :COMPARE reference\gu.wpt %TMPDIR%\gpspilot.gpu\r
+\r
+REM Cetus GPS for PalmOS\r
+REM This test is also similar to the NAV Companion test.\r
+DEL %TMPDIR%\cetus.pdb %TMPDIR%\cetus.gpu %TMPDIR%\cetust.gpu\r
+%PNAME% -i geo -f geocaching.loc -o cetus -F %TMPDIR%\cetus.pdb\r
+%PNAME% -i cetus -f %TMPDIR%\cetus.pdb -o gpsutil -F %TMPDIR%\cetus.gpu\r
+%PNAME% -i cetus -f reference\cetus.pdb -o gpsutil -F %TMPDIR%\cetust.gpu\r
+CALL :COMPARE %TMPDIR%\cetust.gpu %TMPDIR%\cetus.gpu\r
+CALL :COMPARE reference\cetus.gpu %TMPDIR%\cetus.gpu\r
+\r
+REM QuoVadis GPS for PalmOS\r
+REM This test is derived from the Cetus test above.\r
+DEL %TMPDIR%\quovadis.pdb %TMPDIR%\quovadis.gpu %TMPDIR%\quovadist.gpu\r
+%PNAME% -i geo -f geocaching.loc -o quovadis -F %TMPDIR%\quovadis.pdb\r
+%PNAME% -i quovadis -f %TMPDIR%\quovadis.pdb -o gpsutil -F %TMPDIR%\quovadis.gpu\r
+%PNAME% -i quovadis -f reference\quovadis.pdb -o gpsutil -F %TMPDIR%\quovadist.gpu\r
+CALL :COMPARE %TMPDIR%\quovadist.gpu %TMPDIR%\quovadis.gpu\r
+CALL :COMPARE reference\quovadis.gpu %TMPDIR%\quovadis.gpu\r
+\r
+REM GpsDrive\r
+DEL %TMPDIR%\gpsdrive.txt\r
+%PNAME% -i geo -f geocaching.loc -o gpsdrive -F %TMPDIR%\gpsdrive.txt\r
+CALL :COMPARE %TMPDIR%\gpsdrive.txt reference\r
+%PNAME% -i gpsdrive -f reference\gpsdrive.txt -o gpsdrive -F %TMPDIR%\gpsdrive2.txt\r
+CALL :COMPARE %TMPDIR%\gpsdrive2.txt reference\gpsdrive.txt\r
+\r
+REM XMapHH Street Atlas USA file format\r
+DEL %TMPDIR%\xmapwpt.wpt %TMPDIR%\xmapwpt.xmapwpt\r
+%PNAME% -i xmapwpt -f reference\xmapwpt.wpt -o xmapwpt -F %TMPDIR%\xmapwpt.xmapwpt\r
+%PNAME% -i xmapwpt -f %TMPDIR%\xmapwpt.xmapwpt -o xmapwpt -F %TMPDIR%\xmapwpt.wpt\r
+CALL :COMPARE %TMPDIR%\xmapwpt.wpt reference\r
+\r
+REM XCSV\r
+REM Test that we can parse a style file, and read and write data in the \r
+REM same xcsv format (a complete test is virtually impossible).\r
+ECHO RECORD_DELIMITER NEWLINE> %TMPDIR%\testo.style\r
+ECHO FIELD_DELIMITER COMMA>> %TMPDIR%\testo.style\r
+ECHO BADCHARS COMMA>> %TMPDIR%\testo.style\r
+ECHO PROLOGUE Header>> %TMPDIR%\testo.style\r
+ECHO EPILOGUE Footer>> %TMPDIR%\testo.style\r
+ECHO IFIELD SHORTNAME,,%%s>> %TMPDIR%\testo.style\r
+ECHO IFIELD LAT_DIRDECIMAL,,%%c%%lf>> %TMPDIR%\testo.style\r
+ECHO IFIELD LON_DECIMALDIR,,%%lf%%c>> %TMPDIR%\testo.style\r
+DEL %TMPDIR%\xcsv.geo %TMPDIR%\xcsv.xcsv\r
+%PNAME% -i geo -f geocaching.loc -o xcsv,style=%TMPDIR%\testo.style -F %TMPDIR%\xcsv.geo\r
+%PNAME% -i xcsv,style=%TMPDIR%\testo.style -f %TMPDIR%\xcsv.geo -o xcsv,style=%TMPDIR%\testo.style -F %TMPDIR%\xcsv.xcsv\r
+CALL :COMPARE %TMPDIR%\xcsv.geo %TMPDIR%\xcsv.xcsv\r
+\r
+REM Garmin Mapsource This is a binary format with some undocumented\r
+REM fields. This test is therefore intentionally vague. We read a file,\r
+REM convert it to GPX, then write a file as MPS, then read it back and\r
+REM write it as GPX and compare them. Since we're writing both GPX files\r
+REM ourselves from the same version, we're immune to changes in our own\r
+REM GPX output.\r
+\r
+%PNAME% -i mapsource -f reference\mapsource.mps -o gpx -F %TMPDIR%\ms1.gpx\r
+%PNAME% -i mapsource -f reference\mapsource.mps -o mapsource -F %TMPDIR%\ms.mps\r
+%PNAME% -i mapsource -f %TMPDIR%\ms.mps -o gpx -F %TMPDIR%\ms2.gpx\r
+CALL :COMPARE %TMPDIR%\ms1.gpx %TMPDIR%\ms2.gpx\r
+REM\r
+REM MRCB mapsource track test\r
+REM\r
+DEL %TMPDIR%\mps-track.mps\r
+%PNAME% -t -i mapsource -f reference\track\mps-track.mps -o mapsource -F %TMPDIR%\mps-track.mps\r
+CALL :COMPARE %TMPDIR%\mps-track.mps reference\track\r
+REM\r
+REM Geocaching Database is a binary Palm format that, like the GPX variants\r
+REM has a zillion "equivalent" encodings of any given record set. So we\r
+REM read the reference file, spin it to GPX and back to GCDB and then spin\r
+REM that one to GPX.\r
+REM\r
+\r
+%PNAME% -i gcdb -f reference\GeocachingDB.PDB -o gpx -F %TMPDIR%\gcdb1.gpx -o gcdb -F %TMPDIR%\gcdb1.pdb\r
+%PNAME% -i gpx -f %TMPDIR%\gcdb1.gpx -o gpx -F %TMPDIR%\gcdb2.gpx\r
+CALL :COMPARE %TMPDIR%\gcdb1.gpx %TMPDIR%\gcdb1.gpx\r
+\r
+REM\r
+REM Duplicate filter - Since filters have no format of their own, we use csv\r
+REM as an intermediate format for testing the filter.\r
+REM\r
+DEL %TMPDIR%\filterdupe.csv1 %TMPDIR%\filterdupe.csv2\r
+%PNAME% -i geo -f geocaching.loc -o csv -F %TMPDIR%\filterdupe.csv1\r
+%PNAME% -i geo -f geocaching.loc -f geocaching.loc -x duplicate,shortname -o csv -F %TMPDIR%\filterdupe.csv2\r
+CALL :SORTandCOMPARE %TMPDIR%\filterdupe.csv1 %TMPDIR%\filterdupe.csv2\r
+\r
+REM\r
+REM Position filter - Since very small distances are essentialy a duplicate \r
+REM position filter, we can test very similarly to the duplicate filter.\r
+REM\r
+DEL %TMPDIR%\filterpos.csv1 %TMPDIR%\filterpos.csv2\r
+%PNAME% -i geo -f geocaching.loc -o csv -F %TMPDIR%\filterpos.csv1\r
+%PNAME% -i geo -f geocaching.loc -f geocaching.loc -x position,distance=5f -o csv -F %TMPDIR%\filterpos.csv2\r
+CALL :SORTandCOMPARE %TMPDIR%\filterpos.csv1 %TMPDIR%\filterpos.csv2\r
+\r
+REM\r
+REM Radius filter\r
+REM\r
+DEL %TMPDIR%\radius.csv\r
+%PNAME% -i geo -f geocaching.loc -x radius,lat=35.9720,lon=-87.1347,distance=14.7 -o csv -F %TMPDIR%\radius.csv\r
+CALL :COMPARE %TMPDIR%\radius.csv reference\r
+REM\r
+REM magellan SD card waypoint / route format\r
+REM\r
+DEL %TMPDIR%\magellan.rte\r
+%PNAME% -r -i magellan -f reference\route\magellan.rte -o magellan -F %TMPDIR%\magellan.rte\r
+CALL :COMPARE %TMPDIR%\magellan.rte reference\route\magellan.rte\r
+\r
+REM\r
+REM GPX routes -- since GPX contains a date stamp, tests will always\r
+REM fail, so we use magellan as an interim format...\r
+REM\r
+DEL %TMPDIR%\gpxroute.gpx %TMPDIR%\maggpx.rte\r
+%PNAME% -r -i gpx -f reference\route\route.gpx -o gpx -F %TMPDIR%\gpxroute.gpx\r
+%PNAME% -r -i gpx -f %TMPDIR%\gpxroute.gpx -o magellan -F %TMPDIR%\maggpx.rte\r
+CALL :COMPARE %TMPDIR%\maggpx.rte reference\route\magellan.rte\r
+\r
+REM\r
+REM MAPSEND waypoint / route format\r
+REM\r
+DEL %TMPDIR%\route.mapsend\r
+%PNAME% -r -i mapsend -f reference\route\route.mapsend -o mapsend -F %TMPDIR%\route.mapsend\r
+CALL :COMPARE %TMPDIR%\route.mapsend reference\route\r
+REM\r
+REM MAPSEND track format \r
+REM\r
+DEL %TMPDIR%\mapsend.trk\r
+%PNAME% -t -i mapsend -f reference\track\mapsend.trk -o mapsend -F %TMPDIR%\mapsend.trk\r
+CALL :COMPARE %TMPDIR%\mapsend.trk reference\track\r
+REM\r
+REM copilot\r
+REM\r
+DEL %TMPDIR%\copilot.pdb\r
+%PNAME% -i copilot -f reference\UKultralight.pdb -o copilot -F %TMPDIR%\cop.pdb\r
+%PNAME% -i copilot -f reference\UKultralight.pdb -o gpx -F %TMPDIR%\cop1.gpx\r
+%PNAME% -i copilot -f %TMPDIR%\cop.pdb -o gpx -F %TMPDIR%\cop2.gpx\r
+CALL :COMPARE %TMPDIR%\cop1.gpx %TMPDIR%\cop2.gpx\r
+\r
+REM\r
+REM EasyGPS. Another binary format.\r
+REM\r
+DEL %TMPDIR%\easy.loc\r
+%PNAME% -i easygps -f reference\easygps.loc -o easygps -F %TMPDIR%\ez.loc\r
+%PNAME% -i easygps -f reference\easygps.loc -o gpx -F %TMPDIR%\ez1.gpx\r
+%PNAME% -i easygps -f %TMPDIR%\ez.loc -o gpx -F %TMPDIR%\ez2.gpx\r
+CALL :COMPARE %TMPDIR%\ez1.gpx %TMPDIR%\ez2.gpx\r
+\r
+REM\r
+REM GPilotS. A Palm format. Another binary format that \r
+REM\r
+REM rm -f ${TMPDIR/gpilots.l\r
+REM${PNAME} -i easygps -f reference/gpilots.pdb -o gpx -F ${TMPDIR}/gp.gpx\r
+%PNAME% -i geo -f geocaching.loc -o gpilots -F %TMPDIR%\blah.pdb\r
+%PNAME% -i gpilots -f %TMPDIR%\blah.pdb -o gpx -F %TMPDIR%\1.gpx\r
+%PNAME% -i gpilots -f reference\gpilots.pdb -o gpx -F %TMPDIR%\2.gpx\r
+CALL :COMPARE %TMPDIR%\1.gpx %TMPDIR%\2.gpx\r
+REM${PNAME} -i easygps -f reference/gpilots.pdb -o gpx -F ${TMPDIR}/gp.gpx\r
+\r
+REM\r
+REM Navicache.\r
+%PNAME% -i navicache -f reference\navicache.xml -o gpsutil -F %TMPDIR%\navi.wpt\r
+CALL :COMPARE %TMPDIR%\navi.wpt reference\navicache.ref\r
+REM\r
+\r
+REM\r
+REM Arc Distance filter\r
+REM\r
+DEL %TMPDIR%\arcdist.txt\r
+%PNAME% -i xmap -f reference\arcdist_input.txt -x arc,file=reference\arcdist_arc.txt,distance=1 -o xmap -F %TMPDIR%\arcdist.txt\r
+CALL :COMPARE %TMPDIR%\arcdist.txt reference\arcdist_output.txt\r
+\r
+REM\r
+REM Polygon filter\r
+REM\r
+DEL %TMPDIR%\polygon.txt\r
+%PNAME% -i xmap -f reference\arcdist_input.txt -x polygon,file=reference\polygon_allencty.txt -o xmap -F %TMPDIR%\polygon.txt\r
+CALL :COMPARE %TMPDIR%\polygon.txt reference\polygon_output.txt\r
+\r
+\r
+\r
+\r
+REM\r
+REM This is nasty. If we have a dictionary handy, treat it as a list of\r
+REM waypoints and reduce all the names to eight characters. Fewer chars\r
+REM results in lost waypoints currently and that's a defect.\r
+REM\r